package com.bw.books.controller;

import com.bw.books.domain.Books;
import com.bw.books.service.BooksService;
import com.shopgoods.common.core.web.controller.BaseController;
import com.shopgoods.common.core.web.domain.AjaxResult;
import org.dromara.easyes.annotation.IndexName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName BooksController
 * @Description 描述
 * @Author GYW
 * @Date 2024-11-20 21:58
 */
@RestController
@RequestMapping("/books")
@IndexName("books")
public class BooksController extends BaseController {


    @Autowired
    private BooksService booksService;

    /**
     * 查询所有
     * @return
     */
    @PostMapping("/findList")
    public AjaxResult findList(){
        return success(booksService.list());
    }


    /**
     * 添加
     */
    @PutMapping("/add")
    public AjaxResult add(Books books){
        return success(booksService.save(books));
    }

    /**
     * 修改
     */
    @GetMapping("/updateBooks")
    public AjaxResult updateBooks(Books books){
        return success(booksService.updateBooks(books));
    }
/**
 *
true	bid	     4  Integer	false	主键
true	title	钢铁是怎样炼成的	String	false	书名
true	price	111	Number	false	价格
true	number	99	Integer	false	数量
true	author	奥斯特洛夫斯基	String	false	作者
 */
    /**
     * 删除
     * @param bid
     * @return
     */
    @DeleteMapping("/delete/{bid}")
    public AjaxResult delete(@PathVariable Integer bid){
        return success(booksService.removeById(bid));
    }




}
